//
//  MKUIElementListViewCellSelection+Test.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2023/10/31.
//  Copyright © 2023 moon. All rights reserved.
//

#import "MKUIElementListViewCellSelection+Test.h"

#define TESTDEF_EnumTypeSelectOptions(EnumType,EnumList) + (MKUIElementListViewCellSelection *)testElement##EnumType:(NSString *)title selected:(EnumType)selectedValue whenDone:(void(^)(EnumType selectedValue))block{\
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];\
    el.elementView.titleText = title;\
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {\
        EnumType selectedValue = (EnumType)[(NSNumber *)el.selectedValue integerValue];\
        el.detailText = [NSString stringWith##EnumType:selectedValue];\
        if(block){\
            block(selectedValue);\
        }\
    };\
    el.elementView.detailText = [NSString stringWith##EnumType:selectedValue];\
    el.elementView.options = [MKUIElementSelectOption optionsWithValues:EnumList textBlock:^NSString * _Nonnull(id  _Nonnull value) {\
        EnumType enumValue = (EnumType)[(NSNumber *)value integerValue];\
        return [NSString stringWith##EnumType:enumValue];\
    }];\
    el.elementView.selectedValue = @(selectedValue);\
    return el;\
}


#define TESTDEF_OptionsEnumTypeSelectOptions(EnumType,EnumList) + (MKUIElementListViewCellSelection *)testElement##EnumType:(NSString *)title selected:(EnumType)selectedValue whenDone:(void(^)(EnumType selectedValue))block{\
    EnumType allEnumvalue = (EnumType)NSUIntegerMax;\
    for(NSNumber *num in EnumList){\
        EnumType v1 = (EnumType)num.integerValue;\
        BOOL allMatch = YES;\
        for(NSNumber *other in EnumList){\
            EnumType v2 = (EnumType)other.integerValue;\
            if(v1==v2)continue;\
            if((v1&v2)==0){\
                allMatch = NO;\
                break;\
            }\
        }\
        if(allMatch){\
            allEnumvalue = v1;\
            break;\
        }\
    }\
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];\
    el.elementView.allowsMultipleSelection = YES;\
    el.elementView.titleText = title;\
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {\
        EnumType selectedValue = (EnumType)0;\
        for(MKUIElementSelectOption *obj in el.selectedOptions){\
            EnumType enumValue = (EnumType)[(NSNumber *)obj.value integerValue];\
            if(enumValue==allEnumvalue){\
                selectedValue = allEnumvalue;\
                break;\
            }\
            selectedValue |= enumValue;\
        }\
        if(block){\
            block(selectedValue);\
        }\
    };\
    el.elementView.detailText = [NSString stringWith##EnumType:selectedValue];\
    el.elementView.options = [MKUIElementSelectOption optionsWithValues:EnumList textBlock:^NSString * _Nonnull(id  _Nonnull value) {\
        EnumType enumValue = (EnumType)[(NSNumber *)value integerValue];\
        return [NSString stringWith##EnumType:enumValue];\
    }];\
    el.elementView.selectedOptions = [el.elementView.options mk_map:^id _Nullable(MKUIElementSelectOption * _Nonnull obj) {\
        EnumType enumValue = (EnumType)[(NSNumber *)obj.value integerValue];\
        if(enumValue==selectedValue) return obj;\
        if(enumValue==allEnumvalue) return nil;\
        if(allEnumvalue==selectedValue) return nil;\
        if(selectedValue==NSUIntegerMax) return nil;\
        if(selectedValue==NSIntegerMax) return nil;\
        if(selectedValue==NSIntegerMin) return nil;\
        if((enumValue&selectedValue)!=0) return obj;\
        return nil;\
    }];\
    return el;\
}

@interface Test_MKUIElementSelectOptionTableViewCell_UIColor : MKUIElementSelectOptionTableViewCell
@property(nonatomic,strong) UIView *colorView;
@property(nonatomic,strong) MKUIFlowLayoutConstraint *flowlayout;
@end
@implementation Test_MKUIElementSelectOptionTableViewCell_UIColor
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.colorView = [[UIView alloc] init];
        self.colorView.frame = CGRectMake(0, 0, 30, 30);
        //
        self.elementView.accessView = self.colorView;
    }
    return self;
}
- (void)customReloadCellModel{
    [super customReloadCellModel];
    MKUIElementSelectOption *option = self.cellModel.modelValue;
    self.colorView.backgroundColor = option.value;
}
@end

@implementation MKUIElementListViewCellSelection (Test)
+ (MKUIElementListViewCellSelection *)testUIColorElementWithTitle:(NSString *)title selected:(UIColor *)selectedValue whenDone:(void(^)(UIColor *selectedValue))block{
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];
    el.elementView.titleText = title;
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {
        el.detailLabel.textColor = el.selectedValue;
        if(block){
            block(el.selectedValue);
        }
    };
    el.elementView.detailLabel.textColor = selectedValue;
    el.elementView.optionCellClass = Test_MKUIElementSelectOptionTableViewCell_UIColor.class;
    el.elementView.options = [MKUIElementSelectOption optionsWithTexts:@[
        @"列表分隔线颜色",
        @"列表线背景色",
        @"单元格选中色",
        @"列表分组背景色",
        @"Black",
        @"Dark",
        @"Light",
        @"White",
        @"Gray",
        @"Red",
        @"Blue",
        @"Cyan",
        @"Yellow",
        @"Magenta",
        @"Orange",
        @"Purple",
        @"Brown",
        @"Clear",
    ] values:@[
        UIColor.mk_listViewSeparatorColor,
        UIColor.mk_listViewBackgroundColor,
        UIColor.mk_listViewCellSelectedColor,
        UIColor.mk_listViewGroupBackgroundColor,
        UIColor.blackColor,
        UIColor.darkGrayColor,
        UIColor.lightGrayColor,
        UIColor.whiteColor,
        UIColor.grayColor,
        UIColor.redColor,
        UIColor.blueColor,
        UIColor.cyanColor,
        UIColor.yellowColor,
        UIColor.magentaColor,
        UIColor.orangeColor,
        UIColor.purpleColor,
        UIColor.brownColor,
        UIColor.clearColor,
    ]];
    el.elementView.selectedValue = selectedValue;
    return el;
}
+ (MKUIElementListViewCellSelection *)testUIEdgeInsetsElementWithTitle:(NSString *)title selected:(UIEdgeInsets)selectedValue whenDone:(void(^)(UIEdgeInsets selectedValue))block{
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];
    el.elementView.titleText = title;
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {
        UIEdgeInsets selectedValue = [(NSValue *)el.selectedValue UIEdgeInsetsValue];
        el.detailText = [NSString stringWithFormat:@"(%@, %@, %@, %@)",@(selectedValue.top),@(selectedValue.left),@(selectedValue.bottom),@(selectedValue.right)];
        if(block){
            block(selectedValue);
        }
    };
    el.elementView.detailText = [NSString stringWithFormat:@"(%@, %@, %@, %@)",@(selectedValue.top),@(selectedValue.left),@(selectedValue.bottom),@(selectedValue.right)];
    el.elementView.options = [MKUIElementSelectOption optionsWithTexts:@[
        @"(0, 0, 0, 0)",
        @"(10, 10, 10, 10)",
        @"(5, 10, 15, 20)",
        @"(5, 10, 15, 60)",
        @"(10, 0, 0, 0)",
        @"(0, 10, 0, 0)",
        @"(0, 0, 10, 0)",
        @"(0, 0, 0, 10)",
    ] values:@[
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)],
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)],
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(5, 10, 15, 20)],
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(5, 10, 15, 60)],
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(10, 0, 0, 0)],
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 0)],
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 0, 10, 0)],
        [NSValue valueWithUIEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 10)],
    ]];
    el.elementView.selectedValue = [NSValue valueWithUIEdgeInsets:selectedValue];
    return el;
}
+ (MKUIElementListViewCellSelection *)testNSIntegerElementWithTitle:(NSString *)title selected:(NSInteger)selectedValue whenDone:(void(^)(NSInteger selectedValue))block{
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];
    el.elementView.titleText = title;
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {
        NSInteger selectedValue = [(NSNumber *)el.selectedValue integerValue];
        el.detailText = @(selectedValue).stringValue;
        if(block){
            block(selectedValue);
        }
    };
    el.elementView.detailText = @(selectedValue).stringValue;
    NSMutableArray<MKUIElementSelectOption *> *options = [[NSMutableArray alloc] init];
    for(int i=-5;i<=30;i++){
        [options addObject:[MKUIElementSelectOption optionWithValue:@(i) text:@(i).stringValue]];
    }
    NSInteger max = 1000000;
    [options addObject:[MKUIElementSelectOption optionWithValue:@(max) text:@(max).stringValue]];
    el.elementView.options = options;
    el.elementView.selectedValue = @(selectedValue);
    return el;
}
+ (MKUIElementListViewCellSelection *)testAlphaElementWithTitle:(NSString *)title selected:(CGFloat)selectedValue whenDone:(void(^)(CGFloat selectedValue))block{
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];
    el.elementView.titleText = title;
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {
        CGFloat selectedValue = [(NSNumber *)el.selectedValue floatValue];
        el.detailText = @(selectedValue).stringValue;
        if(block){
            block(selectedValue);
        }
    };
    el.elementView.detailText = @(selectedValue).stringValue;
    NSMutableArray<MKUIElementSelectOption *> *options = [[NSMutableArray alloc] init];
    for(int i=0;i<=10;i++){
        NSNumber *n = @(i/10.0);
        [options addObject:[MKUIElementSelectOption optionWithValue:n text:n.stringValue]];
    }
    el.elementView.options = options;
    el.elementView.selectedValue = @(selectedValue);
    return el;
}
+ (MKUIElementListViewCellSelection *)testCGSizeElementWithTitle:(NSString *)title selected:(CGSize)selectedValue whenDone:(void(^)(CGSize selectedValue))block{
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];
    el.elementView.titleText = title;
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {
        CGSize selectedValue = [(NSValue *)el.selectedValue CGSizeValue];
        el.detailText = [NSString stringWithFormat:@"%@,%@",@(selectedValue.width),@(selectedValue.height)];
        if(block){
            block(selectedValue);
        }
    };
    el.elementView.detailText = [NSString stringWithFormat:@"%@,%@",@(selectedValue.width),@(selectedValue.height)];
    NSMutableArray<MKUIElementSelectOption *> *options = [[NSMutableArray alloc] init];
    for(int i=0;i<=10;i++){
        for(int j=0;j<10;j++){
            [options addObject:[MKUIElementSelectOption optionWithValue:[NSValue valueWithCGSize:CGSizeMake(i, j)] text:[NSString stringWithFormat:@"%@,%@",@(i),@(j)]]];
        }
        
    }
    el.elementView.options = options;
    el.elementView.selectedValue = [NSValue valueWithCGSize:selectedValue];
    return el;
}
+ (MKUIElementListViewCellSelection *)testNSStringElementWithTitle:(NSString *)title selected:(NSString *)selectedValue whenDone:(void(^)(NSString *selectedValue))block{
    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];
    el.elementView.titleText = title;
    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {
        NSString *selectedValue = el.selectedValue;
        el.detailText = selectedValue;
        if(block){
            block(selectedValue);
        }
    };
    el.elementView.detailText = selectedValue;
    NSMutableArray<MKUIElementSelectOption *> *options = [[NSMutableArray alloc] init];
    
    [options addObject:[MKUIElementSelectOption optionWithValue:nil text:@"nil"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"" text:@"空字符串"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"取消"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"确定"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"删除"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"添加"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"修改"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"1234567890"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"1111111111111111111111111111111111111111111111111111111111111111111111"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"qwertyuiopasdfghjklzxcvbnm"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"qwertyuiop\nasdfghjkl\nzxcvbnm"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"离思五首·其四"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"曾经沧海难为水，除却巫山不是云。 取次花丛懒回顾，半缘修道半缘君。"]];
    [options addObject:[MKUIElementSelectOption optionWithValue:@"曾经沧海难为水，\n除却巫山不是云。\n取次花丛懒回顾，\n半缘修道半缘君。"]];
    
    NSString *max = @"    　　我在好几篇小说中都提到过一座废弃的古园，实际就是地坛。\n\
    　　许多年前旅游业还没有开展，园子荒芜冷落得如同一片野地，很少被人记起。\n\
    　　地坛离我家很近。或者说我家离地坛很近。总之，只好认为这是缘分。地坛在我出生前四百多年就座落在那儿了，而自从我的祖母年轻时带着我父亲来到北京，就一直住在离它不远的地方——五十多年间搬过几次家，可搬来搬去总是在它周围，而且是越搬离它越近了。我常觉得这中间有着宿命的味道：仿佛这古园就是为了等我，而历尽沧桑在那儿等待了四百多年。\n\
    　　它等待我出生，然后又等待我活到最狂妄的年龄上忽地残废了双腿。四百多年里，它一面剥蚀了古殿檐头浮夸的琉璃，淡褪了门壁上炫耀的朱红，坍圮了一段段高墙又散落了玉砌雕栏，祭坛四周的老柏树愈见苍幽，到处的野草荒藤也都茂盛得自在坦荡。\n\
    　　这时候想必我是该来了。十五年前的一个下午，我摇着轮椅进入园中，它为一个失魂落魄的人把一切都准备好了。那时，太阳循着亘古不变的路途正越来越大，也越红。在满园弥漫的沉静光芒中，一个人更容易看到时间，并看见自己的身影。\n\
    自从那个下午我无意中进了这园子，就再没长久地离开过它。\n\
    　　我一下子就理解了它的意图。正如我在一篇小说中所说的：“在人口密聚的城市里，有这样一个宁静的去处，像是上帝的苦心安排。”\n\
    　　两条腿残废后的最初几年，我找不到工作，找不到去路，忽然间几乎什么都找不到了，我就摇了轮椅总是到它那儿去，仅为着那儿是可以逃避一个世界的另一个世界。我在那篇小说中写道：“没处可去我便一天到晚耗在这园子里。跟上班下班一样，别人去上班我就摇了轮椅到这儿来。园子无人看管，上下班时间有些抄近路的人们从园中穿过，园子里活跃一阵，过后便沉寂下来。”\n\
    　　“园墙在金晃晃的空气中斜切下—溜荫凉，我把轮椅开进去，把椅背放倒，坐着或是躺着，看书或者想事，撅一杈树枝左右拍打，驱赶那些和我一样不明白为什么要来这世上的小昆虫。”“蜂儿如一朵小雾稳稳地停在半空；蚂蚁摇头晃脑捋着触须，猛然间想透了什么，转身疾行而去；瓢虫爬得不耐烦了，累了祈祷一回便支开翅膀，忽悠一下升空了；树干上留着一只蝉蜕，寂寞如一间空屋；露水在草叶上滚动，聚集，压弯了草叶轰然坠地摔开万道金光。”\n\
    　　“满园子都是草木竟相生长弄出的响动，悉悉碎碎片刻不息。”这都是真实的记录，园子荒芜但并不衰败。\n\
    　　除去几座殿堂我无法进去，除去那座祭坛我不能上去而只能从各个角度张望它，地坛的每一棵树下我都去过，差不多它的每一米草地上都有过我的车轮印。无论是什么季节，什么天气，什么时间，我都在这园子里呆过。有时候呆一会儿就回家，有时候就呆到满地上都亮起月光。记不清都是在它的哪些角落里了。我一连几小时专心致志地想关于死的事，也以同样的耐心和方式想过我为什么要出生。这样想了好几年，最后事情终于弄明白了：一个人，出生了，这就不再是一个可以辩论的问题，而只是上帝交给他的一个事实；上帝在交给我们这件事实的时候，已经顺便保证了它的结果，所以死是一件不必急于求成的事，死是一个必然会降临的节日。这样想过之后我安心多了，眼前的一切不再那么可怕。比如你起早熬夜准备考试的时候，忽然想起有一个长长的假期在前面等待你，你会不会觉得轻松一点?并且庆幸并且感激这样的安排?剩下的就是怎样活的问题了，这却不是在某一个瞬间就能完全想透的，不是一次性能够解决的事，怕是活多久就要想它多久了，就像是伴你终生的魔鬼或恋人。所以，十五年了，我还是总得到那古园里去，去它的老树下或荒草边或颓墙旁，去默坐，去呆想，去推开耳边的嘈杂理一理纷乱的思绪，去窥看自己的心魂。";
    [options addObject:[MKUIElementSelectOption optionWithValue:max]];
    el.elementView.options = options;
    el.elementView.selectedValue = selectedValue;
    return el;
}
TESTDEF_EnumTypeSelectOptions(MKUItemFlowCollectionViewScrollDirection, (@[
    @(MKUItemFlowCollectionViewScrollDirectionHorizontal),
    @(MKUItemFlowCollectionViewScrollDirectionVertical),
]))
TESTDEF_EnumTypeSelectOptions(MKUIListViewCellSeparatorStyle, (@[
    @(MKUIListViewCellSeparatorStyleNone),
    @(MKUIListViewCellSeparatorStyleSingleLine),
]))
TESTDEF_EnumTypeSelectOptions(UIAlertActionStyle, (@[
    @(UIAlertActionStyleDefault),
    @(UIAlertActionStyleCancel),
    @(UIAlertActionStyleDestructive),
]))
TESTDEF_EnumTypeSelectOptions(UIAlertControllerStyle, (@[
    @(UIAlertControllerStyleAlert),
    @(UIAlertControllerStyleActionSheet),
]))
TESTDEF_EnumTypeSelectOptions(MKUIAlertViewStyle, (@[
    @(MKUIAlertViewStyleAlert),
    @(MKUIAlertViewStyleActionSheet),
]))
TESTDEF_EnumTypeSelectOptions(MKUIAlertActionStyle, (@[
    @(MKUIAlertActionStyleDefault),
    @(MKUIAlertActionStyleCancel),
    @(MKUIAlertActionStyleDestructive),
]))
TESTDEF_EnumTypeSelectOptions(MKUILayoutConstraintDirection, (@[
    @(MKUILayoutConstraintDirectionHorizontal),
    @(MKUILayoutConstraintDirectionVertical),
]))
TESTDEF_EnumTypeSelectOptions(MKUILayoutConstraintVerticalAlignment, (@[
    @(MKUILayoutConstraintVerticalAlignmentTop),
    @(MKUILayoutConstraintVerticalAlignmentCenter),
    @(MKUILayoutConstraintVerticalAlignmentBottom),
]))
TESTDEF_EnumTypeSelectOptions(MKUIEqualDivisionLayoutConstraintParam, (@[
    @(MKUIEqualDivisionLayoutConstraintParam_H_C_C),
    @(MKUIEqualDivisionLayoutConstraintParam_H_C_L),
    @(MKUIEqualDivisionLayoutConstraintParam_H_C_R),
    @(MKUIEqualDivisionLayoutConstraintParam_H_T_C),
    @(MKUIEqualDivisionLayoutConstraintParam_H_T_L),
    @(MKUIEqualDivisionLayoutConstraintParam_H_T_R),
    @(MKUIEqualDivisionLayoutConstraintParam_H_B_L),
    @(MKUIEqualDivisionLayoutConstraintParam_H_B_C),
    @(MKUIEqualDivisionLayoutConstraintParam_H_B_R),
    @(MKUIEqualDivisionLayoutConstraintParam_V_C_C),
    @(MKUIEqualDivisionLayoutConstraintParam_V_C_L),
    @(MKUIEqualDivisionLayoutConstraintParam_V_C_R),
    @(MKUIEqualDivisionLayoutConstraintParam_V_T_C),
    @(MKUIEqualDivisionLayoutConstraintParam_V_T_L),
    @(MKUIEqualDivisionLayoutConstraintParam_V_T_R),
    @(MKUIEqualDivisionLayoutConstraintParam_V_B_C),
    @(MKUIEqualDivisionLayoutConstraintParam_V_B_L),
    @(MKUIEqualDivisionLayoutConstraintParam_V_B_R),
]))
TESTDEF_OptionsEnumTypeSelectOptions(UIPopoverArrowDirection, (@[
    @(UIPopoverArrowDirectionAny),
    @(UIPopoverArrowDirectionUp),
    @(UIPopoverArrowDirectionDown),
    @(UIPopoverArrowDirectionLeft),
    @(UIPopoverArrowDirectionRight),
]))
//+ (MKUIElementListViewCellSelection *)testElementUIPopoverArrowDirection:(NSString *)title selected:(UIPopoverArrowDirection)selectedValue whenDone:(void(^)(UIPopoverArrowDirection selectedValue))block{\
//NSArray *EnumList = @[
//    @(UIPopoverArrowDirectionAny),
//    @(UIPopoverArrowDirectionUp),
//    @(UIPopoverArrowDirectionDown),
//    @(UIPopoverArrowDirectionLeft),
//    @(UIPopoverArrowDirectionRight),
//];
//    UIPopoverArrowDirection allEnumvalue = (UIPopoverArrowDirection)NSUIntegerMax;\
//    for(NSNumber *num in EnumList){\
//        UIPopoverArrowDirection v1 = (UIPopoverArrowDirection)num.integerValue;\
//        BOOL allMatch = YES;\
//        for(NSNumber *other in EnumList){\
//            UIPopoverArrowDirection v2 = (UIPopoverArrowDirection)other.integerValue;\
//            if(v1==v2)continue;\
//            if((v1&v2)==0){\
//                allMatch = NO;\
//                break;\
//            }\
//        }\
//        if(allMatch){\
//            allEnumvalue = v1;\
//            break;\
//        }\
//    }\
//    MKUIElementListViewCellSelection *el = [[MKUIElementListViewCellSelection alloc] init];\
//    el.elementView.allowsMultipleSelection = YES;\
//    el.elementView.titleText = title;\
//    el.elementView.whenDone = ^(__kindof MKUIElementViewSelection * _Nonnull el) {\
//        UIPopoverArrowDirection selectedValue = (UIPopoverArrowDirection)0;\
//        for(MKUIElementSelectOption *obj in el.selectedOptions){\
//            UIPopoverArrowDirection enumValue = (UIPopoverArrowDirection)[(NSNumber *)obj.value integerValue];\
//            if(enumValue==allEnumvalue){\
//                selectedValue = allEnumvalue;\
//                break;\
//            }\
//            selectedValue |= enumValue;\
//        }\
//        if(block){\
//            block(selectedValue);\
//        }\
//    };\
//    el.elementView.detailText = [NSString stringWithUIPopoverArrowDirection:selectedValue];\
//    el.elementView.options = [MKUIElementSelectOption optionsWithValues:EnumList textBlock:^NSString * _Nonnull(id  _Nonnull value) {\
//        UIPopoverArrowDirection enumValue = (UIPopoverArrowDirection)[(NSNumber *)value integerValue];\
//        return [NSString stringWithUIPopoverArrowDirection:enumValue];\
//    }];\
//    el.elementView.selectedOptions = [el.elementView.options mk_map:^id _Nullable(MKUIElementSelectOption * _Nonnull obj) {\
//        UIPopoverArrowDirection enumValue = (UIPopoverArrowDirection)[(NSNumber *)obj.value integerValue];\
//        if(enumValue==selectedValue) return obj;\
//        if(enumValue==allEnumvalue) return nil;\
//        if(allEnumvalue==selectedValue) return nil;\
//        if(selectedValue==NSUIntegerMax) return nil;\
//        if(selectedValue==NSIntegerMax) return nil;\
//        if(selectedValue==NSIntegerMin) return nil;\
//        if((enumValue&selectedValue)!=0) return obj;\
//        return nil;\
//    }];\
//    return el;\
//}
@end

MKDEF_EnumTypeCategories(MKUItemFlowCollectionViewScrollDirection, (@{
    @(MKUItemFlowCollectionViewScrollDirectionHorizontal):@"Horizontal",
    @(MKUItemFlowCollectionViewScrollDirectionVertical):@"Vertical",
}))
MKDEF_EnumTypeCategories(MKUIListViewCellSeparatorStyle, (@{
    @(MKUIListViewCellSeparatorStyleNone):@"None",
    @(MKUIListViewCellSeparatorStyleSingleLine):@"SignleLine",
}))
MKDEF_EnumTypeCategories(UIAlertActionStyle, (@{
    @(UIAlertActionStyleDefault):@"Default",
    @(UIAlertActionStyleCancel):@"Cancel",
    @(UIAlertActionStyleDestructive):@"Destructive",
}))
MKDEF_EnumTypeCategories(UIAlertControllerStyle, (@{
    @(UIAlertControllerStyleAlert):@"Alert",
    @(UIAlertControllerStyleActionSheet):@"ActionSheet",
}))
MKDEF_EnumTypeCategories(MKUIAlertViewStyle, (@{
    @(MKUIAlertViewStyleAlert):@"Alert",
    @(MKUIAlertViewStyleActionSheet):@"ActionSheet",
}))
MKDEF_EnumTypeCategories(MKUIAlertActionStyle, (@{
    @(MKUIAlertActionStyleDefault):@"Default",
    @(MKUIAlertActionStyleCancel):@"Cancel",
    @(MKUIAlertActionStyleDestructive):@"Destructive",
}))
MKDEF_OptionsEnumTypeCategories(UIPopoverArrowDirection, (@{
    @(UIPopoverArrowDirectionUp):@"Up",
    @(UIPopoverArrowDirectionDown):@"Down",
    @(UIPopoverArrowDirectionLeft):@"Left",
    @(UIPopoverArrowDirectionRight):@"Right",
    @(UIPopoverArrowDirectionAny):@"Any",
    @(UIPopoverArrowDirectionUnknown):@"Unknown",
}))
